{*******************************************************************************
* The contents of this file are used with permission, subject to the Mozilla   *
* Public License Version 1.1 (the "License"); you may not use this file except *
* in compliance with the License. You may obtain a copy of the License at      *
* http://www.mozilla.org/MPL/                                                  *
*                                                                              *
* Software distributed under the License is distributed on an "AS IS" basis,   *
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *
* the specific language governing rights and limitations under the License.    *
*                                                                              *
* The Original Code is distributed as part of the "mediate" product and is     *
* Copyright (C) @home media limited. All Rights Reserved.                      *
*                                                                              *
* Email: support@athomemedia.co.uk                                             *
* Web:   http://www.athomemedia.co.uk                                          *
*******************************************************************************}

unit Streamzap;

interface

uses Remotes;

const
  STREAMZAP_DLL = 'Streamzap.dll';
  STREAMZAP_EXE = 'zremote.exe';
  POWER_IR_CMD = 'POWER';

type
  TAHMRemoteStreamZap = class(TAHMRemoteGirder)
  private
  protected
    function CheckDependencies: Boolean; override;
    procedure PopulateMappings; override;
  public
    constructor Create;
  end;

implementation

uses Mapping, Utilities;

constructor TAHMRemoteStreamZap.Create;
begin
  inherited;

  DLLName := STREAMZAP_DLL;
end;

function TAHMRemoteStreamZap.CheckDependencies: Boolean;
begin
  // Streamzap process must be running
  Result := ProcessRunning(STREAMZAP_EXE);
end;

procedure TAHMRemoteStreamZap.PopulateMappings;
begin
  with MappingsInstance do
  begin
    // These mappings correspond to default keybinding profile for mediate
    AddMapping(POWER_IR_CMD, 27, atLaunch);  // Escape (Quit)
    AddMapping('MUTE',         85);  // U
    AddMapping('ONE',          49);  // 1
    AddMapping('TWO',          50);  // 2
    AddMapping('THREE',        51);  // 3
    AddMapping('FOUR',         52);  // 4
    AddMapping('FIVE',         53);  // 5
    AddMapping('SIX',          54);  // 6
    AddMapping('SEVEN',        55);  // 7
    AddMapping('EIGHT',        56);  // 8
    AddMapping('NINE',         57);  // 9
    AddMapping('ZERO',         48);  // 0
    AddMapping('CHANNEL UP',   33);  // PgUp (Scroll Up)
    AddMapping('CHANNEL DOWN', 34);  // PgDn (Scroll Down)
    AddMapping('VOLUME UP',    187); // =
    AddMapping('VOLUME DOWN',  189); // -
    AddMapping('UP',           38);  // Up Arrow
    AddMapping('DOWN',         40);  // Down Arrow
    AddMapping('LEFT',         37);  // Left Arrow
    AddMapping('RIGHT',        39);  // Right Arrow
    AddMapping('OK',           13);  // Enter
    AddMapping('MENU',         77);  // M
    AddMapping('EXIT',         8);   // Backspace
    AddMapping('PLAY',         80);  // P
    AddMapping('PAUSE',        65);  // A
    AddMapping('STOP',         83);  // S
    AddMapping('BACK',         219); // { (Prev Media)
    AddMapping('NEXT',         221); // } (Next Media)
    AddMapping('RECORD',       113); // F2 (Now Playing)
    AddMapping('REWIND',       188); // , (Backward skip)
    AddMapping('FAST FORWARD', 190); // . (Forward skip)
    AddMapping('FAVORITE 1',   114); // Music
    AddMapping('FAVORITE 2',   115); // Video
    AddMapping('FAVORITE 3',   116); // Pictures
    AddMapping('FAVORITE 4',   36);  // Home
  end;
end;


end.
